package cn.edu.nit.sys.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class R {

    private Integer code;
    private String msg;
    private Object data;

    public R(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public static R ok(String msg) {
        return new R(200, msg, null);
    }

    public static R ok(Object data) {
        return new R(200, null, data);
    }

    public static R ok(String msg, Object data) {
        return new R(200, msg, data);
    }

    public static R error(String msg) {
        return new R(300, msg, null);
    }

    public static R login(String msg) {
        return new R(401, msg, null);
    }

    public static R permission() {
        return new R(403, "权限不足", null);
    }

    public static R sys_error() {
        return new R(500, "系统错误", null);
    }
}
